/**
 * 初始化
 */
import shortcut from '@system.shortcut'
let that = null
const boostInit = (_this) => {
  that = _this
  // 屏幕可视高度
  that.screenHeight = GLOBAL_UTILS.global_data.screenHeight
  // 广告素材宽度
  that.defaultStyle.imageWidth = that.isAuditUser ? 702 : 342
  checkInstallShortCut()
}
// 获取相关应用配置信息
const getApplyConfig = (_this) => {
  that = _this
  // 广告六要素
  that.isEleFlag = TACTICS_SDK.getApplyConfig('is_ele_flag_huawei', 'B', true)
  // 素材关闭按钮
  that.isShowMaterialClose = TACTICS_SDK.getApplyConfig('is_show_material_close', 'B', true)
  // 原生视频是否静音播放 
  that.isVoiceNative = TACTICS_SDK.getApplyConfig('is_voice_native', 'B', true)

  // @btnType: 透明：1，合规：2，点距阵：3
  // @btnClickPercent：true:按钮，false:素材

  that.btnType = that.nativeAdvObj.styleType.indexOf('m') !== -1 ? AD_SDK.ad_sdk_global.adNewPostionConfig.btn_adcustom : AD_SDK.ad_sdk_global.adNewPostionConfig.btn_adb
  that.btnClickPercent = Math.floor(Math.random() * 101) <= Number(AD_SDK.ad_sdk_global.adNewPostionConfig.btn_click_percent)
  that.isImgClick = that.nativeAdvObj.styleType.indexOf('m') !== -1 && that.btnClickPercent ? false : true // 控制素材、按钮位置
  //是否使用透明样式
  that.place = that.btnType != 2 ? 'place' : ''
}
/**
 * 检查是否需要弹加桌弹窗
 */
const checkInstallShortCut = () => {
  shortcut.hasInstalled({
    success: function (data) {
      that.isIcon = data
    },
  })
}
const boostUtil = {
  boostInit,
  getApplyConfig,
}
export default boostUtil
